// MongoDB 数据库结构定义
// 由于 MongoDB 是 NoSQL 数据库，使用 Schema 来定义数据结构

// Todo 模型结构定义
const todoSchema = {
  title: {
    type: String,
    required: true,
    description: "任务标题"
  },
  description: {
    type: String,
    required: false,
    description: "任务描述"
  },
  dueDate: {
    type: Date,
    required: false,
    description: "截止日期"
  },
  priority: {
    type: String,
    enum: ['low', 'medium', 'high'],
    default: 'medium',
    description: "优先级"
  },
  category: {
    type: String,
    enum: ['work', 'study', 'life'],
    default: 'work',
    description: "分类"
  },
  tags: {
    type: [String],
    description: "标签数组"
  },
  completed: {
    type: Boolean,
    default: false,
    description: "完成状态"
  },
  completedAt: {
    type: Date,
    required: false,
    description: "完成时间"
  },
  repeatRule: {
    type: String,
    enum: ['none', 'daily', 'weekly', 'monthly', 'yearly'],
    default: 'none',
    description: "重复规则"
  },
  reminderTime: {
    type: Date,
    required: false,
    description: "提醒时间"
  },
  createdAt: {
    type: Date,
    default: Date.now,
    description: "创建时间"
  },
  updatedAt: {
    type: Date,
    default: Date.now,
    description: "更新时间"
  }
};

// 如果需要在 MongoDB 中创建索引，可以使用以下语句：
/*
db.todos.createIndex({ "createdAt": 1 })
db.todos.createIndex({ "dueDate": 1 })
db.todos.createIndex({ "priority": 1 })
db.todos.createIndex({ "category": 1 })
db.todos.createIndex({ "completed": 1 })
*/

module.exports = { todoSchema };